package com.hww.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

import javax.annotation.PostConstruct;

/**
 * @Author: heweiwei
 * @Date: 4/27/25 PM4:17
 * @Description:
 */
public class LifeCycleBean implements InitializingBean, DisposableBean, BeanNameAware, BeanFactoryAware {

    private String someProperty;


    public LifeCycleBean() {
        System.out.println("1. LifeCycleBean no args constructor");
    }

    // 属性注入，setter方法
    public void setSomeProperty(String someProperty) {
        System.out.println("2. 属性注入，setter方法被调用,someProperty:" + someProperty);
    }


    @Override
    public void setBeanName(String name) {
        System.out.println("3. aware invoke");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("4. beanFactory,aware invoke");
    }


    @PostConstruct
    public void init() {
        System.out.println("6. PostConstruct init");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("7.InitializingBean, afterPropertiesSet ");
    }


    @Override
    public void destroy() throws Exception {
        System.out.println("9. DisposableBean destroy");

    }



}
